#region Copyright 2009 by Mike Podonyi, Licensed under the GNU Lesser General Public License
/*  This file is part of Console.Net.

 *  Console.Net is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.

 *  Console.Net is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.

 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Console.Net.  If not, see <http://www.gnu.org/licenses/>.
 */
#endregion

using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;

namespace Empi.Consolenet
{
    internal class DataBucket
    {

        internal DataBucket(XDocument document)
        {
            XCLIStructure = document;
        }

        internal readonly XDocument XCLIStructure;

        internal static readonly XNamespace MainNameSpace = "urn:consolenet:main:1";

        internal IEnumerable<XElement> XGlobalOptions
        {
            get { return XCLIStructure.Element(MainNameSpace + "console.net").Elements(MainNameSpace + "globaloptions").Elements(MainNameSpace + "option"); }
        }

        private IEnumerable<OptionDom> _GlobalOptions;
        internal IEnumerable<OptionDom> GlobalOptions
        {
            get
            {
                if (_GlobalOptions == null)
                {
                    _GlobalOptions = from i in XGlobalOptions
                                        select new OptionDom(this,i);
                }

                return _GlobalOptions;
            }
        }
    }

    internal static class StringHelper
    {
        internal static string[] SplitMe(this string source)
        {
            return source.Split(',');
        }
    }
}